﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ViCode_LeVi.Data;

namespace ViCode_LeVi.Controls
{
    public static class VMTabHeaders
    {
        public static List<VMTabHeader> ListIntances = new List<VMTabHeader>();
        public static void Add(VMTabHeader tab)
        {
            if (!ListIntances.Contains(tab))
                ListIntances.Add(tab);
        }
        public static void Refresh()
        {
            foreach (var tab in ListIntances)
                tab.RefreshUI();
        }
    }
    /// <summary>
    /// Interaction logic for VMTabHeader.xaml
    /// </summary>
    public partial class VMTabHeader : UserControl
    {
        public VMTabHeader()
        {
            InitializeComponent();
            VMTabHeaders.Add(this);
            this.DataContext = ProjectData.Intance;
            this.Loaded += new RoutedEventHandler(VMTabHeader_Loaded);
            this.Unloaded += new RoutedEventHandler(VMTabHeader_Unloaded);
            this.LostFocus += new RoutedEventHandler(VMTabHeader_LostFocus);
            DatePicker_CreatedDate.Foreground = new SolidColorBrush(Color.FromRgb(0xB3, 0x00, 0x1A));   
        }

        void VMTabHeader_LostFocus(object sender, RoutedEventArgs e)
        {
            if (ProjectData.Intance != null)
                ProjectData.Intance.SendProperty_ProjectInfo();
        }

        void VMTabHeader_Unloaded(object sender, RoutedEventArgs e)
        {
            if (ProjectData.Intance != null)
                ProjectData.Intance.SendProperty_ProjectInfo();
        }

        void VMTabHeader_Loaded(object sender, RoutedEventArgs e)
        {
            this.DataContext = ProjectData.Intance;
        }
        public void RefreshUI()
        {
            this.DataContext = null; ;
            this.DataContext = ProjectData.Intance;
        }
    }
}
